package cn.smile.dao.common;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import cn.smile.entity.common.Goods;
import cn.smile.entity.common.ReportGoods;
import cn.smile.entity.common.Student;

/**
 * 举报物品数据库操作dao
 */
@SuppressWarnings("JpaQlInspection")
@Repository
public interface ReportGoodsDao extends JpaRepository<ReportGoods, Long>, JpaSpecificationExecutor<ReportGoods> {
    /**
     * 根据id获取
     */
    @Query("select rg from ReportGoods rg where id = :id")
    ReportGoods find(@Param("id") Long id);

    /**
     * 根据学生查询
     */
    List<ReportGoods> findByStudent(Student student);

    /**
     * 根据物品查询
     */
    @SuppressWarnings("unused")
    List<ReportGoods> findByGoods(Goods goods);

    /**
     * 根据学生id和商品id查询
     */
    @Query("select rg from ReportGoods rg where rg.goods.id = :goodsId and rg.student.id = :studentId")
    ReportGoods find(@Param("goodsId") Long goodsId, @Param("studentId") Long studentId);


}
